import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import axios from "axios"
//axios.defaults.baseURL = ""
import ElementPlus from "element-plus"
//样式
import "element-plus/dist/index.css"
import "element-plus/theme-chalk/dark/css-vars.css";
import "animate.css";
import "../src/styles/index.scss";
import { zhCn } from 'element-plus/es/locales.mjs'
import { setupElIcons, setupI18n } from "@/plugins";
import { session } from '@/stores/storageHelper.ts'
//import '@assets/icons'

// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    // 在发送请求之前做些什么
    let token = session.get("token");
    if(token){
      config.headers.Authorization = 'Bearer ' + token;
    }

    return config;
  }, function (error) {

    // 对请求错误做些什么
    return Promise.reject(error);
  });

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
    // 2xx 范围内的状态码都会触发该函数。
    // 对响应数据做点什么
    return response;
  }, function (error) {
    // 超出 2xx 范围的状态码都会触发该函数。
    // 对响应错误做点什么
    return Promise.reject(error);
  });



const app = createApp(App)

app.provide("axios", axios)
app.use(ElementPlus, {
    locale: zhCn
})
setupElIcons(app);
setupI18n(app);
app.use(createPinia())



app.use(router)
app.mount('#app')
